<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="bp" value="${pageContext.request.contextPath}"/>
<jsp:include page="common/header.jsp"/>
    <div id="page-wrapper">
        <div class="row">
            <div class="col-md-12">
                <h1 class="page-header">快速订购</h1>
            </div>
            <!-- /.col-lg-12 -->
        </div>
        <div class="row">
            <div class="col-md-8">

                <table class="table table-striped table-bordered table-hover">
                    <thead>
                    <tr>
                        <th style="width: 12%">蔬菜编号</th>
                        <th style="width: 20%">蔬菜名字</th>
                        <th style="width: 10%">蔬菜价格</th>
                        <th style="width: 20%">蔬菜图片</th>
                        <td style="width: 14%">操作</td>
                    </tr>
                    </thead>
                    <tbody>
                    <c:forEach items="${vegelist}" var="keyword" varStatus="vid">
                        <tr>
                            <td style="width: 12%">${keyword.vid}</td>
                            <td style="width: 20%">${keyword.vname}</td>
                            <td style="width: 10%">${keyword.vprice}</td>
                            <td style="width: 20%">${keyword.vpicture}</td>
                            <td style="width: 14%"><button onclick="quierk(${keyword.vid})">删除</button></td>
                        </tr>
                    </c:forEach>

                    </tbody>
                </table>
                <a href="${bp}/vege/add">添加蔬菜</a>
            </div>

        </div>
    </div>
    <!-- /#page-wrapper -->

</div>
<script type="text/javascript">

    function quierk(vid) {
        $.ajax({
            type:"get",
            url:"${bp}/vege/deleteById",
            data:{"vid":vid},
            success : function (msg) {
                if(msg == 1){
                    window.location="www.baiduc.com"
                    alert("删除成功")
                    window.location.reload()
                }else{
                    alert("删除失败")
                }
            }
        })
    }
</script>
<jsp:include page="common/forwer.jsp" />
</body>

</html>